<?php
// +----------------------------------------------------------------------
// | 座位 模型
// +----------------------------------------------------------------------
namespace app\library\model;
use think\Model;

class Seat extends Model{
    // 定义时间戳字段名
    protected $createTime = 'ctime';
    protected $updateTime = '';
    protected $autoWriteTimestamp = true;
	//添加或修改数据
	public function saveData($data){
		$seat = new Seat;
		$res = $seat->saveAll($data);
		if ($res) {
			return true;
		}
		return false;
	}
    /**
     * 获取分区座位
     * @param int $areaid 选中的ID
     * @return array
     */
	public function getSeatArr($areaid){
    	$seat = new Seat;
    	$res = $seat->where('areaid',$areaid)->select();
    	return $res;
	}
    /**
     * 删除座位
     * @param array $ids id数组
     * @return bool
     */
    public function del($ids = '') {
        if (is_array($ids)) {
            $error = '';
            foreach ($ids as $k => $v) {
                $map = [];
                $map['id'] = $v;
                self::where($map)->delete();
            }
            if ($error) {
                $this->error = $error;
                return false;
            }
            return true;
        }
        $this->error = '参数传递错误';
        return false;
    }
}